define(
	[
		'require'
	],
	function(require){
		var Controller = Ember.Controller.extend({
			isNodeserver:false,
			menus: Ember.computed("model", function(key, value){

				var menu = this.get("model");
				if(arguments.length == 1){
					var ctrl = this;
					var menus = Ember.A();
					menus.isLoading = true;
					setTimeout(function(){
						ctrl.requireNodeMenus(menu.id);
					});
					return menus;
				}else{
					return value;
				}
			}),

			requireNodeMenus:function(nodeId) {
				var ctrl = this;
				this.set("menus.isLoading", true);
				this.store.ajax("GET", "node/menus", {
					nodeId: nodeId
				})
				.then(function(response){
					ctrl.set("menus", Ember.A(response.result));
					ctrl.set("menus.isLoading", false);
					return response.result;
				});
			}
		});
	
		APM.ServiceServerNodeserverController = Controller;

		return Controller;
	}
);	